package gui;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JTextPane;
import javax.swing.JScrollPane;

/**
 * Displays a message area where all recieving messages are displayed
 *
 * @author Dominik Korittki
 * @author Steffen Grushka
 * @version 0.1
 */
public class TextPanel extends JPanel {
	
	private static final long serialVersionUID = 1L;
	private JTextPane txtpnHiWieGehts;

	/**
	 * Create the panel.
	 */
	public TextPanel() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JScrollPane scrollPane = new JScrollPane();
		
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 0;
		gbc_scrollPane.gridy = 0;
		add(scrollPane, gbc_scrollPane);
		
		txtpnHiWieGehts = new JTextPane();
		txtpnHiWieGehts.setEditable(false);
		scrollPane.setViewportView(txtpnHiWieGehts);
	}
	
	/**
	 * Text to append to message display
	 * @param message String which to append
	 */
	public void addText(String message) {
		txtpnHiWieGehts.setText(txtpnHiWieGehts.getText() + message + "\r\n");
	}

}
